package com.publicize.commom.commonutils;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result {
    private boolean success=false;
    private  int code;
    private Map<String,Object> data=new HashMap<>();
    private String message;
    public static Result ok(){
        Result result=new Result();
        result.setSuccess(true);
        result.setCode(200);
        result.setMessage("成功");
        return result;
    }
    public static Result error(){
        Result result=new Result();
        result.setSuccess(false);
        result.setCode(500);
        result.setMessage("失败");
        return result;
    }
    public Result data(String key,Object value){
        this.data.put(key,value);
        return this;
    }
    public Result message(String msg){
        this.message=msg;
        return this;
    }
    public Result code(Integer code){
        this.code=code;
        return this;
    }
}
